import router from '@system.router';
import prompt from '@system.prompt';
export default {
    data: {
        userloginname:'',
        userpassword:'',
        userpassword2:''
    },
    change(e){
        this.userloginname=e.value;
    },
    change1(e){
        this.userpassword=e.value;
    },
    change2(e){
        this.userpassword2=e.value;
    },
    fankui:async function(){
//        向数据库中添加要注册的用户信息
        var actionData = {};
        actionData.userName = this.userloginname;
        actionData.userPassword = this.userpassword;

        var action = {};

        //添加service所在的包名
        action.bundleName = 'com.example.myapplication4';

        //添加service的类名
        action.abilityName = 'com.example.myapplication4.DemoService2';

        //添加messageCode ，用于区分其他的action
        action.messageCode = 100;

        //添加数据
        action.data = actionData;

        //跳转的activity的类型，0代表service
        action.abilityType = 0;

        //最重要的一步：跳转
        var str = await FeatureAbility.callAbility(action);

        //下面是处理 java FA 返回的数据
        var result = JSON.parse(str);
        console.log(result.ans);

        //    this.id=result.id;
        if(result.ans=="success"){
            prompt.showToast({
                message: '注册成功',
                duration: 2000,
            });
            setTimeout(()=>{
                router.back()
            },2000);
        }else if(result.ans=="fail"){
            prompt.showToast({
                message: '注册失败',
                duration: 2000,
            });
        }
    },
}
